'=======================================
' 执行所有测试 case
'=======================================
Private Sub test_ALL_case()
    ' offer 测试
    test_offer
    ' poll 测试
    test_poll
    ' peek 测试
    test_peek
    ' Clear 测试
    test_Clear
    ' 保存 Nothing 测试
    test_save_nothing
End Sub

'=======================================
' 各方法的测试 case
'=======================================
' offer 测试
Private Sub test_offer()
    Dim q As ObjQueue
    Set q = New ObjQueue
    
    Dim c1 As Collection
    Set c1 = New Collection
    Dim c2 As Collection
    Set c2 = New Collection
    
    q.offer c1
    Debug.Assert q.Count = 1
    
    q.offer c2
    Debug.Assert q.Count = 2
    
    q.offer Nothing
    Debug.Assert q.Count = 3
End Sub

' poll 测试
Private Sub test_poll()
    Dim q As ObjQueue
    Set q = New ObjQueue
    
    Dim c1 As Collection
    Set c1 = New Collection
    Dim c2 As Collection
    Set c2 = New Collection
    
    q.offer c1
    Debug.Assert q.Count = 1
    
    q.offer c2
    Debug.Assert q.Count = 2
    
    q.offer Nothing
    Debug.Assert q.Count = 3
    
    Dim cx As Collection
    Set cx = q.poll
    Debug.Assert q.Count = 2
    
    Set cx = q.poll
    Debug.Assert q.Count = 1
    
    Set cx = q.poll
    Debug.Assert cx Is Nothing
    Debug.Assert q.Count = 0
End Sub

' peek 测试
Private Sub test_peek()
    Dim q As ObjQueue
    Set q = New ObjQueue
    
    Dim c1 As Collection
    Set c1 = New Collection
    Dim c2 As Collection
    Set c2 = New Collection
    
    q.offer c1
    q.offer c2
    q.offer Nothing
    Debug.Assert q.Count = 3
    
    Dim cx As Collection
    Set cx = q.peek
    Debug.Assert q.Count = 3
    
    q.poll
    q.poll
    
    Set cx = q.peek
    Debug.Assert cx Is Nothing
    Debug.Assert q.Count = 1
End Sub

' Clear 测试
Private Sub test_Clear()
    Dim q As ObjQueue
    Set q = New ObjQueue
    
    Dim c1 As Collection
    Set c1 = New Collection
    Dim c2 As Collection
    Set c2 = New Collection
    
    q.offer c1
    q.offer c2
    q.offer Nothing
    Debug.Assert q.Count = 3
    
    q.Clear
    Debug.Assert q.Count = 0
    Debug.Assert q.IsEmpty = True
End Sub

' 保存 Nothing 测试
Private Sub test_save_nothing()
    Dim q As ObjQueue
    Set q = New ObjQueue
    
    Debug.Assert q.IsEmpty = True

    q.offer Nothing
    q.offer Nothing
    q.offer Nothing
    
    Debug.Assert q.IsEmpty = False
    Debug.Assert q.Count = 3
End Sub
